import axios from 'axios';

// POST 请求方式
let postAction = function(url, params) {
    return new Promise((resolve, reject)=> {
        axios.post(url, params)
        .then(res=> { resolve(res.data) })
        .catch(error=>{ reject(error);  })
    });
}

// DELETE 请求方式
let deleteAction = function(url, params) {
    return new Promise((resolve, reject)=> {
        axios.delete(url, params)
        .then(res=> { resolve(res.data) })
        .catch(error=>{ reject(error);  })
    });
}

// PUT 请求方式
let putAction = function(url, params) {
    return new Promise((resolve, reject)=> {
        axios.put(url, params)
        .then(res=> { resolve(res.data) })
        .catch(error=>{ reject(error);  })
    });
}

// GET 请求方式
let getAction = function(url, params) {
    return new Promise((resolve, reject)=> {
        axios.get(url, params)
        .then(res=> { resolve(res.data) })
        .catch(error=>{ reject(error);  })
    });
}


export default {
    postAction,
    deleteAction,
    putAction,
    getAction,
}